#!/bin/bash
clear

. /etc/os-release
if [[ "$EUID" -ne 0 ]]; then
    echo -e "\033[1;31mScript need to be run as root!\033[0m" && exit 1
fi

echo
echo 'MIT License

Copyright (c) 2021 Doctype

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.';
echo

sleep 5

echo
echo
echo "Before continue with the setup, we need to ask you 
some questions first"
echo
read -p "Enter your domain: " DOMAIN
read -p "Enter your email: " EMAIL
read -p "Enter your username: " USERNAME
read -p "Enter your password: " PASSWORD

echo "DOMAIN=$DOMAIN" > /etc/environment
echo "EMAIL=$EMAIL" >> /etc/environment
echo "USERNAME=$USERNAME" >> /etc/environment
echo "PASSWORD=$PASSWORD" >> /etc/environment

echo
echo "That all we need for now, we will start the setup now, please wait... "
echo

clear
IPV4=$(wget -qO- ipv4.icanhazip.com)
IPV6=$(wget -qO- ipv6.icanhazip.com)

apt-get update
apt-get -y upgrade
apt-get -y -qq install build-essential
apt-get -y -qq install cmake automake
apt-get -y -qq install curl git zip
apt-get -qq update

ln -sf /usr/share/zoneinfo/zoneinfo /etc/localtime
ln -sf /usr/share/zoneinfo/Asia/Kuala_Lumpur /etc/localtime
timedatectl set-timezone Asia/Kuala_Lumpur

echo "" > /etc/motd
wget -q -O /etc/update-motd.d/10-uname 'https://notabug.org/irwanmohi/Joekers/raw/default/sources/banner'
wget -q -O /etc/issue.net 'https://notabug.org/irwanmohi/Joekers/raw/default/sources/message'

wget -q -O - 'https://notabug.org/irwanmohi/Joekers/raw/default/packages/nginx.sh' | bash
wget -q -O - 'https://notabug.org/irwanmohi/Joekers/raw/default/packages/dropbear.sh' | bash
wget -q -O - 'https://notabug.org/irwanmohi/Joekers/raw/default/packages/ovpn.sh' | bash
wget -q -O - 'https://notabug.org/irwanmohi/Joekers/raw/default/packages/squid.sh' | bash
wget -q -O - 'https://notabug.org/irwanmohi/Joekers/raw/default/packages/stunnel.sh' | bash
wget -q -O - 'https://notabug.org/irwanmohi/Joekers/raw/default/packages/badvpn.sh' | bash

wget -q -O - 'https://notabug.org/irwanmohi/Joekers/raw/default/packages/sslibev.sh' | bash
wget -q -O - 'https://notabug.org/irwanmohi/Joekers/raw/default/packages/v2ray.sh' | bash
wget -q -O - 'https://notabug.org/irwanmohi/Joekers/raw/default/packages/wireguard.sh' | bash
wget -q -O - 'https://notabug.org/irwanmohi/Joekers/raw/default/packages/haproxy.sh' | bash
wget -q -O - 'https://notabug.org/irwanmohi/Joekers/raw/default/packages/tinyproxy.sh' | bash
wget -q -O - 'https://notabug.org/irwanmohi/Joekers/raw/default/packages/ohpserver.sh' | bash
wget -q -O - 'https://notabug.org/irwanmohi/Joekers/raw/default/packages/websocket.sh' | bash

wget -q -O - 'https://notabug.org/irwanmohi/Joekers/raw/default/packages/webmin.sh' | bash
wget -q -O - 'https://notabug.org/irwanmohi/Joekers/raw/default/packages/security.sh' | bash

wget -q -O - 'https://notabug.org/irwanmohi/Joekers/raw/default/packages/plugins.sh' | bash

echo
echo -e "\033[1;32mCongratulation, we are done with the setup.\033[0m"
echo "It's good for you to reboot your server fisrt."
echo
echo 'Use my referral link https://m.do.co/c/a28a40414d6a'
echo 'to gets $100 credit into your DigitalOcean account.'
echo 'Created by Doctype, Powered by Cybertize'
echo 'Copyright 2021, Allright reserved.'
echo
